module.exports = (sequelize, DataTypes) => {
  const SudokuPuzzle = sequelize.define('SudokuPuzzle', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
      comment: '主键ID'
    },
    level: {
      type: DataTypes.ENUM('easy', 'medium', 'hard'),
      allowNull: false,
      comment: '题目难度等级'
    },
    puzzle: {
      type: DataTypes.STRING(81),
      allowNull: false,
      comment: '题目字符串（81位）'
    },
    solution: {
      type: DataTypes.STRING(81),
      allowNull: false,
      comment: '题目答案（81位）'
    },
    clues: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: '题目已知数字数量'
    },
    creator: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: '创建人'
    },
    modifier: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: '修改人'
    },
    isDeleted: {
      type: DataTypes.CHAR(1),
      defaultValue: '0',
      field: 'is_deleted',  // 映射到数据库的实际字段名
      comment: '是否删除（0-未删，1-已删）'
    }
  }, {
    tableName: 'sudoku_puzzles',
    timestamps: true,
    createdAt: 'created_at',
    updatedAt: 'modified_at',
    indexes: [
      {
        fields: ['level']
      },
      {
        fields: ['clues']
      },
      {
        fields: ['isDeleted']
      }
    ]
  });

  return SudokuPuzzle;
};
